package gensqlmap;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * 
* @ClassName: GeneratorSqlmap
* @Description: TODO(这里用一句话描述这个类的作用)
* @author ganquanzhong
* @date 2018年5月4日 下午7:09:40
 */
public class GeneratorSqlmap {

	public void generator() throws Exception{

		List<String> warnings = new ArrayList<String>();
		boolean overwrite = true;

		//指定 逆向工程配置文件
		String url = System.getProperty("user.dir")+"\\src\\test\\resources\\generatorConfig.xml";
		File configFile = new File(url);

		ConfigurationParser cp = new ConfigurationParser(warnings);
		Configuration config = cp.parseConfiguration(configFile);

		DefaultShellCallback callback = new DefaultShellCallback(overwrite);
		MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,
				callback, warnings);
		myBatisGenerator.generate(null);
	}


	public static void main(String[] args) throws Exception {
		try {
			new GeneratorSqlmap().generator();
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("generator 成功！！！");
	}
}
